﻿<?php
	$md = new core\Model('ASSOCIATE','app\libs\Association');
	$lista = $md->read();

	echo "<div class='body' style='padding-left: 15px; width: 90%; margin: auto;'><br/>";

	
	echo "<p><input type='button' class='k-button' value='Nova Associação' onclick='document.location.href=\"/associacao/inclusao\"' /></p>";	
	echo "<table id='grid' class='tbl'>";
	echo "<thead class='tbl'><tr>";		
	echo "<th data-field='id'>ID</th>";
	echo "<th data-field='tabela'>Tabela</th>";	
	echo "<th data-field='classe'>Classe</th>";	
	echo "<th data-field='alterar'>Alterar</th>";	
    echo "</tr>";
	echo "</thead>";
	if($lista){
		echo "<tbody>";				
		foreach($lista as $r){			
			echo "<tr>";			
			echo "<td>{$r->getId()}</td>";
			echo "<td>".strtoupper($r->getTable())."</td>";
			echo "<td>{$r->getClass()}</td>";
			echo "<td><a href='/associacao/alteracao/{$r->getId()}'><img src='/images/icons/page_white_gear.png'></a></td>";
			echo "</tr>";
		}			
		echo "</tbody>";        
	}
	echo "</table>";
	echo "</div>";	
	
?>
	</fieldset>
	<script>
		$(function() {
			$("#grid").kendoGrid({
				height: 500,				
				pageable: {
					pageSize: 20
				},
				filterable: true,
				sortable: true
			});
		});
	</script>